Skip to content

test: drop stale serializer 8.1 getErrors() deprecation expectation#8287

Merged
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:fix/stale-serializer-deprecation-expectation
Jun 13, 2026
Merged

test: drop stale serializer 8.1 getErrors() deprecation expectation#8287
soyuka merged 1 commit into
api-platform:mainfrom
soyuka:fix/stale-serializer-deprecation-expectation

Conversation

@soyuka

@soyuka soyuka commented Jun 10, 2026

Copy link
Copy Markdown
Member

Problem

main CI fails on PHP 8.4/8.5 (all DB + Symfony variants) with 2 test failures:

  • EnumDenormalizationValidationTest::testInvalidBackedEnumValueWithCollectDenormalizationErrors
  • NullOnNonNullablePropertyTest::testNullOnNonNullablePropertyReturns422WhenCollectingErrors

Both:

Expected deprecation with message "Since symfony/serializer 8.1: The
"...PartialDenormalizationException::getErrors()" method is deprecated,
use "...getNotNormalizableValueErrors()" instead." was not triggered

Cause

Since #8211 the denormalization violation factories
(src/Validator/DenormalizationViolationFactory.php,
src/Laravel/State/DenormalizationViolationFactory.php) guard the call:

$errors = method_exists($exception, 'getNotNormalizableValueErrors')
    ? $exception->getNotNormalizableValueErrors()
    : $exception->getErrors();

On symfony/serializer >=8.1 the new method exists, so the deprecated
getErrors() is never called and the deprecation never fires. The
expectUserDeprecationMessage assertions are stale — production code was
fixed to avoid the deprecation, but the expectations weren't removed.

Fix

Remove the expectUserDeprecationMessage blocks from both tests plus the
now-unused VersionParser / InstalledVersions / IgnoreDeprecations
imports.

Verified against symfony/serializer:^8.1 (4/4 pass) and unchanged on
8.0 (the block was already skipped there). php-cs-fixer clean.

Refs #8211

Violation factories use method_exists(getNotNormalizableValueErrors)
since api-platform#8211, so the deprecated getErrors() is never called on
symfony/serializer >=8.1. The deprecation no longer fires, making the
expectUserDeprecationMessage assertion fail with "not triggered".

Remove the expectation from both tests plus the now-unused
VersionParser/InstalledVersions/IgnoreDeprecations imports.

Refs api-platform#8211
@soyuka soyuka merged commit 573df71 into api-platform:main Jun 13, 2026
87 of 96 checks passed
@soyuka soyuka mentioned this pull request Jul 12, 2026
1 task
soyuka added a commit that referenced this pull request Jul 12, 2026
… test

The 3-way merge of #8389 correctly dropped the deprecation-expectation
guard (imports + #[IgnoreDeprecations] + version check) that #8287 had
already removed from the sibling test, since 4.4's DenormalizationViolationFactory
prefers getNotNormalizableValueErrors() over the deprecated getErrors()
whenever it exists and so never triggers that deprecation on symfony/serializer
>=8.1. But #8389 also introduced a brand-new test reusing the same
now-unimported VersionParser/IgnoreDeprecations symbols, which the
textual merge could not reconcile: it left the merged file referencing
classes with no matching use statement. Remove the same stale guard
from the new test for the same reason #8287 removed it from the old one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant